package com.cby.library.common.base

/**
 * 数据信息包
 *
 * @author chenbaoyang
 */
data class DataWrapper<out T>(
    val status: Status,
    val data: T?,
    val errorMsg: String?,
    val page:Int = 0
){
    companion object{

        fun <T> success(data: T?, page: Int = 0): DataWrapper<T> {
            return DataWrapper(Status.SUCCESS, data, null, page)
        }

        fun <T> error(msg: String, data: T?): DataWrapper<T> {
            return DataWrapper(Status.ERROR, data, msg)
        }

        fun <T> loading(data: T?): DataWrapper<T> {
            return DataWrapper(Status.LOADING, data, null)
        }

    }
}